In this demo, you will learn how to
customize the pre built material components in the react app. On the official website of material,
there are several ways available to customize the material
components using hooks or APIs. To customize a material component, install the MUI styles package
first using yarn or NPM. There are three possible API types in the
style package for customizing a component. The first is hook API. Which uses make style as a hook
from the MUI styles package. Hook API accepts the object of
styles as input where you can define the custom styling with key and
value as an object of the style attribute. Use the key as a reference of style within the class name props
of a material component. Pass the class name
value as classes.Route. Where classes will be the instance of use
styles created using make style hook. And route will be the key name
as style ref for components. You can customize the material components
using the styled component API. Import style hook from the MUI styles and
directly customized the material component by passing the components
into the argument of styled hook method. You can customize the material
component by passing custom styles. You can also give a custom name to
the newly customized component using the custom defined components
directly with the style or sub component wrapped into the components. Similarly, you can customize the component
using the higher order component API. Which uses the with style
hook from the MUI styles. The higher order component API, uses
the object of styles that has the key and object value as styles attributes. Past the custom defined style key into the
value of class name props of the material component. The style objects are referenced
from the props as classes. Use style objects as Classes.Route
into the props value of the class name of components. Wrap the component into
the with style hook. And the custom styles object created and
the component that you are customizing. Moving to the code,
you have the surface.jsx file, where the make style method from
the MUI styles has been imported. Add some custom style attributes within
the value of the custom key card. Utilize the styles value under
the material component into the class name props as classes.card and
classes.media. Both the class name props
have a distinctive style. Now save the file and execute it. In the UI,
the card component is customized. The card component is in a different
structure than the usual material UI. The image and
the topography are aligned horizontally. Also, there are lists of
various profiles under it. In this way, you can customize a material component
using the material styles package. Thank you.